from rest_framework import serializers
from .models import *
import datetime


class RecordSerializer(serializers.ModelSerializer):
    start = serializers.SerializerMethodField()
    end = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S")

    def get_start(self, obj):
        # print(type(obj))
        return obj.start.strftime("%Y{}%m{}%d{}").format("年", "月", "日")

    class Meta:
        model = Record
        fields = "__all__"
